package hl.demosample.ui.fragment.progress

import android.os.Bundle
import hl.demosample.R
import hl.demosample.app.base.BaseFragment
import hl.demosample.app.ext.initClose
import hl.demosample.databinding.FragmentCircleProgressBinding
import kotlinx.android.synthetic.main.fragment_circle_progress.*
import kotlinx.android.synthetic.main.include_toolbar.*
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.ext.nav

/*
* path: DemoSample 
* Author: 86133
* Create: 2021-06-02 17:20
* Changes (from 2021-06-02)
* Desc:
*/
class CircleProgressFragment:BaseFragment<BaseViewModel,FragmentCircleProgressBinding>() {

    private val mShaderColors = intArrayOf(-0xb01554, -0x5722af, -0x172cf1, -0x5722af, -0xb01554)

    override fun layoutId()= R.layout.fragment_circle_progress

    override fun initView(savedInstanceState: Bundle?) {

        mDatabind.click = ProxyClick()

        toolbar.initClose(" CircleProgress进度条") {
            nav().navigateUp()
        }
    }

    inner class ProxyClick {
        fun setShowTick(){
            cbTick.setOnCheckedChangeListener { _, isChecked -> cpv.setShowTick(isChecked) }
        }

       fun setTurn(){
           cbTurn.setOnCheckedChangeListener { _, isChecked -> cpv.setTurn(isChecked) }
       }
        fun clickBtn1(){
            cpv.setProgressColor(*mShaderColors)
            cpv.showAnimation(100, 3000)
        }

        fun clickBtn2(){
            cpv.setProgressColor(*mShaderColors)
            cpv.showAnimation(100, 0, 3000)
        }

        fun clickBtn3(){
            cpv.setProgressColor(-0xb01554)
            cpv.showAnimation(100, 3000)
        }

        fun clickBtn4(){
            cpv.setProgressColor(-0xb01554)
            cpv.showAnimation(100, 3000)
        }
    }
}